 // The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import router from './router'
import api from './http'
import store from './store'
import axios from 'axios'
import ElementUI from 'element-ui'
import i18n from './i18n'
import 'element-ui/lib/theme-chalk/index.css'
import 'font-awesome/css/font-awesome.min.css'
import './assets/iconfont/iconfont.css'

Vue.config.productionTip = false
Vue.prototype.$axios = axios //把axios挂载到vue的原型对象上，这样每一个vue的组件都可以通过this直接访问到axios，从而去发起ajax请求
Vue.use(ElementUI)
Vue.use(api)
Vue.prototype.global = global
/* eslint-disable no-new */
//解决vue使用sessionStorage存储数据，页面不能实时更新
// 只需修改xxxxx值，其余无需修改
Vue.prototype.resetSetItem = function(key, newVal) {
  if (key === 'pageResult') {
    // 创建一个StorageEvent事件
    var newStorageEvent = document.createEvent('StorageEvent')
    const storage = {
      setItem: function(k, val) {
        sessionStorage.setItem(k, val)
        // 初始化创建的事件
        newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null)
        // 派发对象
        window.dispatchEvent(newStorageEvent)
      }
    }
    return storage.setItem(key, newVal)
  }
}


new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})

